<template>
  <div class="app-container p-rel">
    <div class="container-title">文书下发管理</div>
    <!-- <form-edit class="p-abs" :detailForm="detailForm" :isEdit="isEdit" @submitForm="submitForm" :editVisible.sync="editVisible" v-if="editVisible"></form-edit> -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="85px">
      <el-row :gutter="15">
        <el-col :lg="8" :xl="6">
          <el-form-item label="文书名称" prop="docName" label-width="150px">
            <el-input
              v-model="queryParams.docName"
              placeholder="请输入文书名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>

        <el-col :lg="8" :xl="6">
          <el-form-item label="处罚对象" prop="enterpriseName" label-width="150px">
            <el-input
              v-model="queryParams.enterpriseName"
              placeholder="处罚对象"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
            <el-button type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
            <el-button icon="" size="" @click="resetQuery">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          size="mini"
          type="primary"
          @click="handleAdd"
        >添加</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="infoList">
      <el-table-column type="index" width="55" align="center"  label="序号"/>
      <el-table-column label="监督对象" align="center" prop="enterpriseName"/>
      <el-table-column label="监督专业" align="center" prop="major" />
      <el-table-column label="经营地址" align="center" prop="businessAddress" />
      <el-table-column label="监管员" align="center" prop="supervisor" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="文书名称" align="center" prop="docName" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200px">
        <template slot-scope="scope">
          <el-button
              style="margin-right:6px"
              size="mini"
              type="text"
              @click="handleTest(scope.row)"
          >查看详情</el-button>
         <el-popconfirm 
            title="确定删除该条数据吗？"
            :hide-icon="true"
            @confirm="handleTest(scope.row,'DELETE')"
            @cancel="handleCancel"
         >
              <el-button
                size="mini"
                type="text"
                slot="reference"
              >删除</el-button>
         </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSupervisoryInstrumentFn"
    />
  </div>
</template>

<script>
import { getSupervisoryInstrument,supervisionWritDelete} from "@/api/zhangping/occupational";
export default {
  name: "Info",
  data() {
    return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        infoList: [],
        // spotCheck:{},
        // dispositionData:'',
        // planComplete:'',
        // 查询参数
        queryParams: {  
            docName:'',
            enterpriseName:'',
            pageNum: 1,
            pageSize: 10,
        },
     };
  },
  created() {
     this.loading = false
     this.getSupervisoryInstrumentFn()
  },
  methods: {
       // 获取列表 
    getSupervisoryInstrumentFn(){
         getSupervisoryInstrument(this.queryParams).then(res=>{
                if(res.code == 200){
                     this.infoList = res.rows
                     this.total = res.total
                }else{
                     this.$message.error(res.msg);  
                }    
         })
    },
    supervisionWritDeleteFn(item){
        let data ={
                  id:item.id,
                }
         supervisionWritDelete(data).then(res=>{
                if(res.code == 200){
                      this.$message.success(res.msg);
                      this.getSupervisoryInstrumentFn()
                      this.reset()
                }else{
                      this.$message.error(res.msg);  
                }    
          })
                
    },
    confirm(){

    },
    // submitForm(){
    //      this.getSaveRandomGenFn()
    // },
    // 表单重置
    reset() {
      this.queryParams = {
            docName:'',
            enterpriseName:'',
            pageNum: 1,
            pageSize: 10,
      };
    },
    handleAdd(){

    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getSupervisoryInstrumentFn()
    },
    handleTest(item,type){  
          if(type === 'DELETE'){
              this.supervisionWritDeleteFn(item)    
          }else{
              // this.scaleOpen = true
              // this.getDispositionFn()
          }
    },
    handleInfo(){

    },
    cancel(){
         this.open = false
         this.scaleOpen = false
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.handleQuery();
    },
  
  
   }
};
</script>
